<div style="height: 30px; border-bottom: 4px solid #DFDFDF;">
	<p class="pull-left" style="font-size: 16px; line-height: 30px;">
		<strong><?php echo $this->translate('订单管理'); ?> - (<?php echo $this->translate('订单数：').$this->order_list->getTotalItemCount(); ?>)</strong>
	</p>
	<p class="pull-right">
        <!--<a href="<?php echo $this->url('orders/default',array('action'=>'moreshipoper','controller'=>'Orders')); ?>" class="btn btn-primary btn-small"><i class="icon-plane icon-white"></i> <?php echo $this->translate('批量订单发货'); ?></a>&nbsp;&nbsp;-->
<!--		<a href="--><?php //echo $this->myviewalias()->dbshopHelpUrl('order_set'); ?><!--" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> --><?php //echo $this->translate('查看帮助说明'); ?><!--</a>-->
	</p>
</div>

<input type="hidden" name="edit_type" id="edit_type" value="">
<table class="table table-hover">
	<thead style="background: #CCC;">
		<tr>
			<th width="3%">
				<input type="checkbox" id="select_checkbox_state" onclick="selectCheckBox('order_id', 'select_checkbox_state');">
			</th>
			<th width="12%"><?php echo $this->translate('订单号'); ?></th>
			<th width="12%"><?php echo $this->translate('购买人'); ?></th>
            <!--<th width="10%"><?php echo $this->translate('收货人'); ?></th>-->
			<th width="8%"><?php echo $this->translate('订单状态'); ?></th>
			<!--<th width="8%"><?php echo $this->translate('支付方式'); ?></th>-->
			<th width="8%"><?php echo $this->translate('订单总额'); ?></th>
			<th width="10%"><?php echo $this->translate('下单时间'); ?></th>
            <th width="10%"><?php echo $this->translate('管理员'); ?></th>
			<th width="10%"><?php echo $this->translate('操作'); ?></th>
		</tr>
	</thead>
	<form method="GET" action="">
		<tr class="goods_search" style="background: #F5F5F5;">
			<td></td>
			<td>
					<input type="text" name="order_sn"
						value="<?php if (isset($this->searchArray['order_sn'])) echo $this->searchArray['order_sn']; ?>"
					 class="span11">
			</td>
			<td>
				<input type="text" name="buyer_name"
					value="<?php if (isset($this->searchArray['buyer_name'])) echo $this->searchArray['buyer_name']; ?>"
					class="span11">
			</td>
			<!--<td>
				<p>
					<input type="text" name="delivery_name"
						value="<?php if (isset($this->searchArray['delivery_name'])) echo $this->searchArray['delivery_name']; ?>"
						class="span11">
				</p>
			</td>-->
			<td>
			<!--	<select id="order_state" name="order_state" class="span8">
					<option value=""><?php echo $this->translate('默认状态'); ?></option>
                    <option value="0" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] != '' and $this->searchArray['order_state'] == 0) echo 'selected="selected"'; ?>><?php echo $this->translate('已取消'); ?></option>
                    <option value="10" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 10) echo 'selected="selected"'; ?>><?php echo $this->translate('待付款'); ?></option>
                    <option value="15" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 15) echo 'selected="selected"'; ?>><?php echo $this->translate('付款中'); ?></option>
                    <option value="20" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 20) echo 'selected="selected"'; ?>><?php echo $this->translate('已付款'); ?></option>
                    <option value="30" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 30) echo 'selected="selected"'; ?>><?php echo $this->translate('待发货'); ?></option>
                    <option value="40" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 40) echo 'selected="selected"'; ?>><?php echo $this->translate('已发货'); ?></option>
                    <option value="60" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 60) echo 'selected="selected"'; ?>><?php echo $this->translate('订单完成'); ?></option>
				</select>
				-->
                <select  name="order_state" class="span8">
                    <option value=""><?php echo $this->translate('默认状态'); ?></option>

                    <option value="10" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 10) echo 'selected="selected"'; ?>><?php echo $this->translate('未付款'); ?></option>
                    <option value="20" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 20) echo 'selected="selected"'; ?>><?php echo $this->translate('已付款'); ?></option>
                    <option value="60" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 60) echo 'selected="selected"'; ?>><?php echo $this->translate('订单完成'); ?></option>
                    <!-- <option value="15" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 15) echo 'selected="selected"'; ?>><?php echo $this->translate('付款中'); ?></option>
						<option value="30" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 30) echo 'selected="selected"'; ?>><?php echo $this->translate('待发货'); ?></option>
						<option value="40" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 40) echo 'selected="selected"'; ?>><?php echo $this->translate('已发货'); ?></option>
						<option value="0" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] != '' and $this->searchArray['order_state'] == 0) echo 'selected="selected"'; ?>><?php echo $this->translate('已取消'); ?></option>
						-->
                </select>
			</td>
			<!--<td>
				<?php $paymentArray = $this->DbshopCommonFun()->dbshopPaymentNameArray(); ?>
				<select id="pay_code" name="pay_code" class="span10">
					<option value=""><?php echo $this->translate('支付方式'); ?></option>
					<?php foreach($paymentArray as $payKey => $payValue) { ?>
					<option value="<?php echo $payKey; ?>" <?php if (isset($this->searchArray['pay_code']) and $this->searchArray['pay_code'] == $payKey) echo 'selected="selected"'; ?>><?php echo $payValue; ?></option>
					<?php } ?>
				</select>
			</td>-->
			<td>
				<p><?php echo $this->translate('始'); ?><input type="text" name="order_start_price" id="order_start_price" value="<?php if ($this->searchArray and  isset($this->searchArray['order_start_price'])) echo $this->searchArray['order_start_price']; ?>" class="span8"></p>
                <p><?php echo $this->translate('终'); ?><input type="text" name="order_end_price" id="order_end_price" value="<?php if ($this->searchArray and isset($this->searchArray['order_end_price'])) echo $this->searchArray['order_end_price']; ?>" class="span8"></p>
			</td>
			<td>
				<p><?php echo $this->translate('始'); ?><input type="text" name="search_start_time" id="search_start_time" value="<?php if ($this->searchArray and isset($this->searchArray['search_start_time'])) echo $this->searchArray['search_start_time']; ?>" onclick="WdatePicker({el:'search_start_time',dateFmt:'yyyy-MM-dd HH:00:00'})" class="span8"></p>
                <p><?php echo $this->translate('终'); ?><input type="text" name="search_end_time" id="search_end_time" value="<?php if ($this->searchArray and isset($this->searchArray['search_end_time'])) echo $this->searchArray['search_end_time']; ?>" onclick="WdatePicker({el:'search_end_time',dateFmt:'yyyy-MM-dd HH:00:00'})" class="span8"></p>
			</td>

            <td>
                <input type="text" name="admin_name"
                       value="<?php if (isset($this->searchArray['admin_name'])) echo $this->searchArray['admin_name']; ?>"
                       class="span11">
            </td>
			<td>
				<p>
					<button class="btn btn-small btn-primary" type="submit"
						onclick="$('#edit_type').val('search');">
						<i class="icon-search icon-white"></i>
						<?php echo $this->translate('搜索'); ?>
					</button>
					&nbsp;
<!--					<button class="btn btn-small btn-primary" type="button"-->
<!--							onclick="advSearch();">-->
<!--						<i class="icon-search icon-white"></i>-->
<!--						--><?php //echo $this->translate('高级搜索'); ?>
<!--					</button>-->
				</p>
                <?php if ($this->searchArray and !empty($this->searchArray)) { ?>
				<p>
					<a
						href="<?php echo $this->url('Etutororders/default'); ?>"
						class="btn btn-small">
						<i class="icon-arrow-left"></i>
						<?php echo $this->translate('返回'); ?>
					</a>
				</p>
                <?php } ?>
			</td>
		</tr>
	</form>
	<form method="POST"
		action="<?php echo $this->url('Etutororders/default',array('controller'=>'Etutororders', 'action'=>'editOrderAll')); ?>">
             <?php
			 foreach ($this->order_list as $order_value) { ?>
            <tr>
			<td>
				<input name="order_id[]" type="checkbox"
					value="<?php echo $order_value['order_id']; ?>">
			</td>
			<td><?php echo $order_value['order_sn']; ?></td>
			<td><?php echo $this->escapeHtml($order_value['buyer_name']); ?></td>
			<!--<td><?php echo $this->escapeHtml($order_value['delivery_name']); ?></td>-->
			<td>
				<?php echo $this->frontwebsite()->getOneOrderStateInfo($order_value['order_state']); ?>
				<?php if($order_value['refund_state'] == 1) echo ' [<strong style="color: red;">'.$this->translate('已退货').'</strong>]'; ?>
			</td>
			<!--<td>
				<?php echo $order_value['pay_name']; ?>
			</td>-->

			<td>
				<?php echo $order_value['currency_symbol'] . $order_value['order_amount'] . $order_value['currency_unit']; ?>
			</td>
			<td><?php echo date("Y-m-d H:i",$order_value['order_time']); ?></td>
            <td><?php echo $this->escapeHtml($order_value['admin_name']); ?></td>
			<td>
				<a href="<?php echo $this->url('Etutororders/default/order_id',array('action'=>'edit','controller'=>'Etutororders','order_id'=>$order_value['order_id'],'page'=>$this->page), array('query'=>$this->searchArray)); ?>"><?php echo ($order_value['refund_state'] == 1 ? $this->translate('详情查看') : $this->translate('编辑查看')); ?></a>
              <!--  <span>|</span>
                <a target="_blank" href="<?php echo $this->url('Etutororders/default/order_id',array('action'=>'orderprint','controller'=>'Etutororders','order_id'=>$order_value['order_id'])); ?>"><?php echo $this->translate('打印订单'); ?></a>
                -->
			</td>
		</tr>
            <?php } ?>
            <tr>
			<td colspan="12" style="background: #FFF">
				<div class="span6 pull-left" style="height: 30px; line-height: 30px;">
					<input type="checkbox" id="select_checkbox_state_1" onclick="selectCheckBox('order_id', 'select_checkbox_state_1');">
					&nbsp;<?php echo $this->translate('全选操作'); ?>&nbsp;
					<select class="span3" name="allEdit" id="allEdit" onchange="">
						<option value=""><?php echo $this->translate('请选择'); ?></option>
						<option value="del"><?php echo $this->translate('删除'); ?></option>
                        <?php
                        foreach ($this->admin_name_list as $admin_name_value) { ?>
                            <option value= <?php echo $admin_name_value; ?>><?php echo $this->translate('分配订单').$admin_name_value; ?></option>
                        <?php } ?>

					</select>
                    <button type="submit" onclick="return editAllOrders();" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('提交操作'); ?></button>
				</div>
				<?php echo ( count($this->order_list) > 0 ) ? $this->paginationControl($this->order_list, 'Sliding', 'common/pager',array('page_url'=>$this->url('orders/default/page',array('controller'=>'Orders', 'action'=>'index')))) : ""; ?>
                </td>
		</tr>
	</form>
</table>
<form class="form-horizontal" name="order_advsearch_form" id="order_advsearch_form" method="get">
	<div id="myIntegralModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="myModalLabel"><?php echo $this->translate('订单高级搜索'); ?></h3>
		</div>
		<div class="modal-body">
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('订单号'); ?></label>
				<div class="controls">
					<input type="text" class="span8" name="order_sn" value="<?php if (isset($this->searchArray['order_sn'])) echo $this->searchArray['order_sn']; ?>">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('订单状态'); ?></label>
				<div class="controls">
					<select  name="order_state" class="span6">
						<option value=""><?php echo $this->translate('默认状态'); ?></option>

						<option value="10" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 10) echo 'selected="selected"'; ?>><?php echo $this->translate('未付款'); ?></option>
                        <option value="20" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 20) echo 'selected="selected"'; ?>><?php echo $this->translate('已付款'); ?></option>
                        <option value="60" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 60) echo 'selected="selected"'; ?>><?php echo $this->translate('订单完成'); ?></option>
                        <!-- <option value="15" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 15) echo 'selected="selected"'; ?>><?php echo $this->translate('付款中'); ?></option>
						<option value="30" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 30) echo 'selected="selected"'; ?>><?php echo $this->translate('待发货'); ?></option>
						<option value="40" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] == 40) echo 'selected="selected"'; ?>><?php echo $this->translate('已发货'); ?></option>
						<option value="0" <?php if (isset($this->searchArray['order_state']) and $this->searchArray['order_state'] != '' and $this->searchArray['order_state'] == 0) echo 'selected="selected"'; ?>><?php echo $this->translate('已取消'); ?></option>
						-->
					</select>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('订单总额'); ?></label>
				<div class="controls">
					<input type="text" class="span5" name="order_start_price" value="<?php if (isset($this->searchArray['order_start_price'])) echo $this->searchArray['order_start_price']; ?>">
					~
					<input type="text" class="span5" name="order_end_price" value="<?php if (isset($this->searchArray['order_end_price'])) echo $this->searchArray['order_end_price']; ?>">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('下单时间'); ?></label>
				<div class="controls">
					<input type="text" class="span5" id="adv_search_start_time" name="search_start_time" onclick="WdatePicker({el:'adv_search_start_time',dateFmt:'yyyy-MM-dd HH:00:00'})" value="<?php if ($this->searchArray and isset($this->searchArray['search_start_time'])) echo $this->searchArray['search_start_time']; ?>">
					~
					<input type="text" class="span5" id="adv_search_end_time" name="search_end_time" onclick="WdatePicker({el:'adv_search_end_time',dateFmt:'yyyy-MM-dd HH:00:00'})" value="<?php if ($this->searchArray and isset($this->searchArray['search_end_time'])) echo $this->searchArray['search_end_time']; ?>">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('配送方式'); ?></label>
				<div class="controls">
					<select name="express_id" id="express_id" class="span4">
						<option value=""><?php echo $this->translate('选择配送方式'); ?></option>
						<?php if(!empty($this->express_array)) {
							foreach($this->express_array as $express_value) {
								?>
								<option value="<?php echo $express_value['express_id']; ?>" <?php if (isset($this->searchArray['express_id']) and $this->searchArray['express_id'] == $express_value['express_id']) echo 'selected="selected"'; ?>><?php echo $this->escapeHtml($express_value['express_name']); ?></option>
								<?php
							}
						}
						?>
					</select>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('购买人'); ?></label>
				<div class="controls">
					<input type="text" class="span6" name="buyer_name" value="<?php if (isset($this->searchArray['buyer_name'])) echo $this->searchArray['buyer_name']; ?>">
				</div>
			</div>
		<!--	<div class="control-group">
				<label class="control-label"><?php echo $this->translate('收货人'); ?></label>
				<div class="controls">
					<input type="text" class="span6" name="delivery_name" value="<?php if (isset($this->searchArray['delivery_name'])) echo $this->searchArray['delivery_name']; ?>">
				</div>
			</div>  -->
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('收货地区'); ?></label>
				<div class="controls" id="region">
					<span id="show_region_value"></span>
					<select id="show_address_area" class="span8">
						<option value=""><?php echo $this->translate('请选择'); ?></option>
						<?php if ($this->region_array and !empty($this->region_array )) {
							foreach($this->region_array as $value) {
								?>
								<option value="<?php echo $value['region_id']; ?>"><?php echo $value['region_name']; ?></option>
								<?php
							}
						}
						?>
					</select>
					<input type="hidden" name="region_id" id="region_id" value="" class="region_ids">
					<input type="hidden" name="region_value" id="region_value" value="" class="region_names" />
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('地址'); ?></label>
				<div class="controls">
					<input type="text" class="span6" name="region_address" value="<?php if (isset($this->searchArray['region_address'])) echo $this->searchArray['region_address']; ?>">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('电话'); ?></label>
				<div class="controls">
					<input type="text" class="span6" name="phone" value="<?php if (isset($this->searchArray['phone'])) echo $this->searchArray['phone']; ?>">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><?php echo $this->translate('邮编'); ?></label>
				<div class="controls">
					<input type="text" class="span6" name="zip_code" value="<?php if (isset($this->searchArray['zip_code'])) echo $this->searchArray['zip_code']; ?>">
				</div>
			</div>
		</div>
		<div class="modal-footer">
			<button type="submit" class="btn btn-primary"><?php echo $this->translate('点击查询'); ?></button>
		</div>
	</div>
</form>
<script src="<?php echo $this->basePath('/public/js/DatePicker/WdatePicker.js'); ?>"></script>
<script>
function editAllOrders() {
	var num = 0;
	$("input[name='order_id[]']").each(function() {
		if (this.checked == true) {
			num++;
		}
	});
	if(num < 1) {
		alert('<?php echo $this->translate('请至少选择一条订单信息！'); ?>');
		return false;
	}else {
		if($("#allEdit").val()=='') {
			alert('<?php echo $this->translate('请选择操作事件！'); ?>');
			return false;
		}
		if ($("#allEdit").val()=='del') {
            return window.confirm('<?php echo $this->translate('只能删除订单状态为 已取消 的订单，您确实要执行该操作吗？'); ?>');
        }else {
            return window.confirm('<?php echo $this->translate('您确实要将订单分配给该管理员吗？'); ?>');
        }

	}
}

function advSearch() {
	$('#myIntegralModal').modal('show');
}

var SITE_REGION_URL  = '<?php echo $this->url('region/default/region_type',array('action'=>'selectregion','controller'=>'region','module'=>'region','region_type'=>'region_top_id')); ?>';
var AREA_SELECT_LANG = '<?php echo $this->translate('请选择'); ?>';
regionInit("region");
</script>